unit CommUpDown;

{$ALIGN ON}
{$MINENUMSIZE 4}
{$WEAKPACKAGEUNIT}

interface

uses Windows, Messages;

const
{$IFDEF MSWINDOWS}
  cctrl = comctl32; { From Windows.pas }
{$ENDIF}
{$IFDEF LINUX}
  cctrl = 'libcomctl32.borland.so';
{$ENDIF}

  {$EXTERNALSYM UDN_FIRST}
  UDN_FIRST                = 0-721;       { updown }
  {$EXTERNALSYM UDN_LAST}
  UDN_LAST                 = 0-740;

  {$EXTERNALSYM CCM_FIRST}
  CCM_FIRST               = $2000;      { Common control shared messages }

  {$EXTERNALSYM CCM_SETCOLORSCHEME}
  CCM_SETCOLORSCHEME      = CCM_FIRST + 2; // lParam is color scheme
  {$EXTERNALSYM CCM_GETCOLORSCHEME}
  CCM_GETCOLORSCHEME      = CCM_FIRST + 3; // fills in COLORSCHEME pointed to by lParam
  {$EXTERNALSYM CCM_GETDROPTARGET}
  CCM_GETDROPTARGET       = CCM_FIRST + 4;
  {$EXTERNALSYM CCM_SETUNICODEFORMAT}
  CCM_SETUNICODEFORMAT    = CCM_FIRST + 5;
  {$EXTERNALSYM CCM_GETUNICODEFORMAT}
  CCM_GETUNICODEFORMAT    = CCM_FIRST + 6;



{ ====== UPDOWN CONTROL ========================== }

const
  {$EXTERNALSYM UPDOWN_CLASS}
  UPDOWN_CLASS = 'msctls_updown32';

type
  PUDAccel = ^TUDAccel;
  {$EXTERNALSYM _UDACCEL}
  _UDACCEL = packed record
    nSec: UINT;
    nInc: UINT;
  end;
  TUDAccel = _UDACCEL;
  {$EXTERNALSYM UDACCEL}
  UDACCEL = _UDACCEL;

const
  {$EXTERNALSYM UD_MAXVAL}
  UD_MAXVAL               = $7fff;
  {$EXTERNALSYM UD_MINVAL}
  UD_MINVAL               = -UD_MAXVAL;

  {$EXTERNALSYM UDS_WRAP}
  UDS_WRAP                = $0001;
  {$EXTERNALSYM UDS_SETBUDDYINT}
  UDS_SETBUDDYINT         = $0002;
  {$EXTERNALSYM UDS_ALIGNRIGHT}
  UDS_ALIGNRIGHT          = $0004;
  {$EXTERNALSYM UDS_ALIGNLEFT}
  UDS_ALIGNLEFT           = $0008;
  {$EXTERNALSYM UDS_AUTOBUDDY}
  UDS_AUTOBUDDY           = $0010;
  {$EXTERNALSYM UDS_ARROWKEYS}
  UDS_ARROWKEYS           = $0020;
  {$EXTERNALSYM UDS_HORZ}
  UDS_HORZ                = $0040;
  {$EXTERNALSYM UDS_NOTHOUSANDS}
  UDS_NOTHOUSANDS         = $0080;
  {$EXTERNALSYM UDS_HOTTRACK}
  UDS_HOTTRACK            = $0100;


  {$EXTERNALSYM UDM_SETRANGE}
  UDM_SETRANGE            = WM_USER+101;
  {$EXTERNALSYM UDM_GETRANGE}
  UDM_GETRANGE            = WM_USER+102;
  {$EXTERNALSYM UDM_SETPOS}
  UDM_SETPOS              = WM_USER+103;
  {$EXTERNALSYM UDM_GETPOS}
  UDM_GETPOS              = WM_USER+104;
  {$EXTERNALSYM UDM_SETBUDDY}
  UDM_SETBUDDY            = WM_USER+105;
  {$EXTERNALSYM UDM_GETBUDDY}
  UDM_GETBUDDY            = WM_USER+106;
  {$EXTERNALSYM UDM_SETACCEL}
  UDM_SETACCEL            = WM_USER+107;
  {$EXTERNALSYM UDM_GETACCEL}
  UDM_GETACCEL            = WM_USER+108;
  {$EXTERNALSYM UDM_SETBASE}
  UDM_SETBASE             = WM_USER+109;
  {$EXTERNALSYM UDM_GETBASE}
  UDM_GETBASE             = WM_USER+110;
  {$EXTERNALSYM UDM_SETRANGE32}
  UDM_SETRANGE32          = WM_USER+111;
  {$EXTERNALSYM UDM_GETRANGE32}
  UDM_GETRANGE32          = WM_USER+112; // wParam & lParam are LPINT
  {$EXTERNALSYM UDM_SETUNICODEFORMAT}
  UDM_SETUNICODEFORMAT    = CCM_SETUNICODEFORMAT;
  {$EXTERNALSYM UDM_GETUNICODEFORMAT}
  UDM_GETUNICODEFORMAT    = CCM_GETUNICODEFORMAT;

{$EXTERNALSYM CreateUpDownControl}
function CreateUpDownControl(dwStyle: Longint; X, Y, CX, CY: Integer;
  hParent: HWND;  nID: Integer; hInst: THandle; hBuddy: HWND;
  nUpper, nLower, nPos: Integer): HWND; stdcall;

type
  PNMUpDown = ^TNMUpDown;
  {$EXTERNALSYM _NM_UPDOWN}
  _NM_UPDOWN = packed record
    hdr: TNMHDR;
    iPos: Integer;
    iDelta: Integer;
  end;
  TNMUpDown = _NM_UPDOWN;
  {$EXTERNALSYM NM_UPDOWN}
  NM_UPDOWN = _NM_UPDOWN;

const
  {$EXTERNALSYM UDN_DELTAPOS}
  UDN_DELTAPOS = UDN_FIRST - 1;

implementation

{ UpDown control }
function CreateUpDownControl; external cctrl name 'CreateUpDownControl';

end.